package doing;

public class Elevator extends Thread{
	private static final int DELAY=2000;
	
	private Monitor monitor;

	public Elevator(Monitor m) {
		monitor = m;
	}
	
	@Override
	public void run() {
		int dir = 1;
		while (true) {
			int next = monitor.getHere()+dir;
			if (next == 6) {
				dir = -1;
			} else if (next == 0) {
				dir = 1;
			}
			monitor.setNext(next);
			monitor.setHere(next);
			monitor.elevatorWait(next);
			
		}
	}

}
